
class ListNode {
    int val;
    ListNode next;

    ListNode(int val) {
        this.val = val;
    }
}
public class code2 {
    public ListNode reverseList(ListNode head) {
        if (head == null || head.next == null) return head;

        ListNode cur = reverseList(head.next);
        //4.next.next = 4
        head.next.next = head;
        //断开，防止循环成环
        head.next = null;

        return cur;
    }
}